import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import Vant from 'vant';
import axios from 'axios';
import 'vant/lib/index.css';
import './assets/css/global.css';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

Vue.use(Vant);
Vue.config.productionTip = false

axios.defaults.baseURL = "http://192.168.35.26:9101/";
axios.defaults.timeout = 10000;

Vue.config.productionTip = false;
axios.interceptors.request.use(config => {
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
});
axios.interceptors.response.use(config => {
  NProgress.done();
  return config;
});

Vue.prototype.$http = axios;

Vue.filter('distanceFilter', function (distance) {
  return distance < 1000 ? (distance + 'm') : ((distance / 1000).toFixed(1) + 'km');
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
